package com.atsansan.mywork.login.service.impl;

import com.atsansan.mywork.login.dao.UserDao;
import com.atsansan.mywork.login.entity.UserEntity;
import com.atsansan.mywork.login.service.UserService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sansan
 * @create 2021-01-17 22:05
 */
@Service("userService")

public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

    @Override
    public List<UserEntity> list(){
        List<UserEntity> userEntities = baseMapper.selectList(null);
        return userEntities;
    }

    @Override
    public UserEntity selectByName(String name) {

        UserEntity userEntity = baseMapper.selectOne(new QueryWrapper<UserEntity>().eq("name", name));
        return userEntity;
    }

    @Override
    public UserEntity login(String name, String password) {
        UserEntity userEntity = baseMapper.selectOne(new QueryWrapper<UserEntity>().eq("name", name).eq("password", password));

        return userEntity;
    }


}
